#include <bits/stdc++.h>
using namespace std;

using ll = long long;
const ll N = 24;
ll a[N], b[N];
ll mp[N][N], vis[N][N];
ll n;
vector<ll> ans;
bool check()
{
    for (ll i = 1; i <= n; i++)
    {
        if (a[i] || b[i])
        {
            return false;
        }
    }
    return true;
}
void dfs(ll x, ll y)
{
    if (y == n && x == n)
    {
        if (check())
        {
            for (ll i = 0; i < ans.size(); i++)
            {
                cout << ans[i] << " ";
            }
        }
        return;
    }

    ll dx[] = {0, 0, 1, -1};
    ll dy[] = {1, -1, 0, 0};
    for (ll i = 0; i < 4; i++)
    {
        ll tx = dx[i] + x, ty = dy[i] + y;
        if (tx < 1 || tx > n || ty < 1 || ty > n || vis[tx][ty])
        {
            continue;
        }
        else if (a[ty] >= 1 && b[tx] >= 1 && vis[tx][ty] == 0)
        {
            ans.push_back(mp[tx][ty]);
            vis[tx][ty] = 1;
            a[ty]--, b[tx]--;
            dfs(tx, ty);
            vis[tx][ty] = 0;
            a[ty]++, b[tx]++;
            ans.pop_back();
        }
    }
}
int main()
{
    cin >> n;
    for (ll i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    for (ll i = 1; i <= n; i++)
    {
        cin >> b[i];
    }

    ll res = 0;
    for (ll i = 1; i <= n; i++)
    {
        for (ll j = 1; j <= n; j++)
        {
            mp[i][j] = res++;
        }
    }
    ans.push_back(mp[1][1]);
    a[1]--, b[1]--;
    vis[1][1]++;
    dfs(1, 1);
    return 0;
}